from tkinter import*

root=Tk()

text1=Text(root,width=30,height=5,undo=True,autoseparators=False)
text1.pack()

text1.insert(INSERT,"Hello,everyone,my name is Guy!")

# def getIndex(text,index):
#     return tuple(map(int,str.split(text.index(index),".")))

# start="1.0"
# while(True):
#     pos=text1.search("o",start,stopindex=END)
#     if not pos:
#         break
#     print("找到了，位置是：",getIndex(text1,pos))
#     start=pos+'+1c'

#绑定事件都要加上分隔符
def callback(event):
    text1.edit_separator()


text1.bind('<Key>',callback)

def show():
    text1.edit_undo()

Button(root,text="撤销",command=show).pack()

mainloop()